package com.example.demo.core.listener;/**
 * Created by kete on 2017-10-13.
 */

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.HashMap;
import java.util.Map;

/**
 * 作者：kete
 * 创建时间：2017-10-13 17:43
 * 功能描述：
 * 版本：
 */
public class ConfigListener implements ServletContextListener{

    private static Map<String, String> conf = new HashMap<>();

    public static Map<String, String> getConf() {
        return conf;
    }

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        ServletContext sc = servletContextEvent.getServletContext();
        // 项目路径
        conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
        conf.put("contextPath", sc.getContextPath());

    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

        conf.clear();
    }
}
